package targetToOffer.seventhDay;

/**
 * @author Godc
 * @description
 */
public class DeleteNode {
}
class Solution {
    public ListNode deleteNode(ListNode head, int val) {
        ListNode temp = head;
        if (temp.val == val) {
            return temp.next;
        }
        while (temp != null) {
            if (temp.next != null && temp.next.val == val) {
                temp.next = temp.next.next;
            }
            temp = temp.next;
        }
        return head;
    }
}
class ListNode {
      int val;
      ListNode next;
      ListNode(int x) { val = x; }
}